home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / What's New? / Development Kits / Mac OS / USB DDK 1.4.6f4 / USB Software Locator Kit / SampleDriverInstallerExample / ActivateShimAtom.c next >
Encoding:
Text File  |  2000-08-22  |  2.3 KB  |  104 lines  |  [TEXT/MPS ]

  1. //
  2. //    ActivateShimAtom.c
  3. //
  4. //        Demonstration of a format0 action atom and compatibility with
  5. //        Installer Engine 4.1.
  6. //
  7. //        This action atom is designed to make the USBAddShimToDisk call.  USBAddShimToDisk is a
  8. //         new call for USB 1.3.5 which is used to activate a USBShim file long after the startup
  9. //         process.  This actionatom is compiled as a native code resource.
  10. //
  11. //
  12.  
  13. // comment the following out to turn off DebugStr
  14. #define DEBUG    1
  15.  
  16. #include "AtomDefs.h"
  17. #include <Types.h>
  18. #include <Resources.h>
  19. #include <Files.h>
  20. #include <Folders.h>
  21. #include <TextUtils.h>
  22. #include <MixedMode.h>
  23. #include <USB.h>
  24.  
  25. // this line replaces #include "ActionAtomHeader.h" used in previous 4.0.3 action atoms
  26. #include "InstallerScript.h"
  27. ActionAtomResult ActionAtom2Proc( ActionAtom2PBPtr atomRecPtr );
  28.  
  29. enum {
  30.     uppActionAtom2ProcInfo    = kCStackBased
  31.         | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  32.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ActionAtom2PBPtr)))
  33. };
  34.  
  35. ProcInfoType __procinfo = uppActionAtom2ProcInfo;
  36.  
  37. ActionAtomResult ActionAtom2Proc( ActionAtom2PBPtr atomRecPtr )
  38. {
  39.     FSSpec            fsspec;
  40.     StringHandle    strh;
  41.     short            foundRefNum;
  42.     OSStatus        status;
  43.     OSErr            err;
  44.     Boolean            result;
  45.  
  46. #if DEBUG
  47.     DebugStr("\pEntered ActionAtom2Proc");    
  48. #endif
  49.         // check if we are executing at post install time and return if not
  50.     if (atomRecPtr->fMessageID != after)
  51.         return kActionAtomResultContinue;
  52.         
  53.         // only execute if we are doing a live install
  54.     if (atomRecPtr->fDidLiveUpdate != true)
  55.         return kActionAtomResultContinue;
  56.  
  57.     strh = GetString(kShimSTRid);
  58.     if (strh)
  59.     {
  60.         err = FindFolder(atomRecPtr->fTargetVRefNum, kExtensionFolderType, kDontCreateFolder, 
  61.                             &fsspec.vRefNum, &fsspec.parID);
  62.         if (err == noErr)
  63.         {
  64.             BlockMove(*strh, &(fsspec.name), (long)(**strh) + 1);
  65.         
  66.             if ((Ptr) USBAddShimFromDisk != (Ptr) kUnresolvedCFragSymbolAddress)
  67.             {
  68.                 status = USBAddShimFromDisk(&fsspec);
  69.                 if (status != noErr)
  70.                 {
  71. #if DEBUG
  72.                     DebugStr("\p call to ActionAtomFormat2::USBAddShimFromDisk failed");
  73. #endif
  74.                 }
  75.             }
  76.             else
  77.             {
  78. #if DEBUG
  79.                 DebugStr("\p cannot see USBAddShimFromDisk");
  80. #endif
  81.             }
  82.         }
  83.         else
  84.         {
  85. #if DEBUG
  86.             DebugStr("\p call to ActionAtomFormat2::FindFolder failed");
  87. #endif
  88.         }
  89.     }
  90.     else
  91.     {
  92. #if DEBUG
  93.         DebugStr("\p call to ActionAtomFormat2::GetString failed");
  94. #endif
  95.     }
  96.     
  97.     return (kActionAtomResultContinue);
  98. }
  99.  
  100.  
  101.  
  102.  
  103.  
  104.